<?php

namespace ManiaLivePlugins\MLEPP\ServerInfo\Gui\Windows;

use ManiaLive\Event\Dispatcher;
use ManiaLivePlugins\MLEPP\ServerInfo\Gui\Controls\GeneralTab;
use ManiaLivePlugins\MLEPP\ServerInfo\Gui\Controls\CommandsTab;
use ManiaLivePlugins\MLEPP\ServerInfo\Gui\Controls\ServerLinksTab;
use ManiaLivePlugins\MLEPP\ServerInfo\Gui\Controls\PluginsTab;
use ManiaLive\Gui\Windowing\Controls\Tab;
use ManiaLive\Gui\Windowing\Controls\Tabview;
use ManiaLive\Gui\Windowing\Controls\Frame;
use ManiaLive\Gui\Windowing\Controls\Line;
use ManiaLive\Gui\Windowing\Controls\Panel;
use ManiaLib\Gui\Elements\Bgs1;
use ManiaLib\Gui\Elements\Quad;
use ManiaLib\Gui\Elements\Label;

class InfoWindow extends \ManiaLive\Gui\Windowing\ManagedWindow
{
	protected $tabview;

	public static $open = 0;
	public $login;

	function initializeComponents()
	{
		$this->setTitle('Serverinfo');
		$this->setMaximizable();

		// create tabview and fill it with content ...
		$this->tabview = new Tabview();

		// add General tab
		$tab = new GeneralTab();
		$tab->setTitle('General');
		$this->tabview->addTab($tab);

		// add Commands tab
		$tab = new CommandsTab();
		$tab->setTitle('Commands');
		$this->tabview->addTab($tab);

		// add serverlinks tab
		$tab = new ServerLinksTab();
		$tab->setTitle('Server Links');
		$this->tabview->addTab($tab);

		// add plugins tab
		$tab = new PluginsTab();
		$tab->setTitle('Plugins');
		$this->tabview->addTab($tab);

		$this->addComponent($this->tabview);
	}

	function onDraw()
	{

		$this->tabview->setPosition(1, 6);
		$this->tabview->setSize($this->getSizeX() - 2, $this->getSizeY() - 7);
	}

	function onShow()
	{
		self::$open++;
		$this->tabview->getTab(0)->generalList();
		$this->tabview->getTab(1)->commandList($this->login);
		$this->tabview->getTab(2)->joinList();
		$this->tabview->getTab(3)->refreshList();
	}

	function onHide()
	{
		self::$open--;

	}

	function destroy()
	{
		unset($this->tabview);
		gc_collect_cycles();
		parent::destroy();
	}

}

?>